package main

import "fmt"

type Student struct {
	name  string
	age   int
	Score map[string]string
}

func main() {
	/*
	   1、直接实例化
	*/
	stu2 := Student{
		name: "baim0",
		age:  26,
		Score: map[string]string{
			"语文": "60",
			"数学": "60",
			"英语": "60",
		},
	}
	fmt.Printf("%v\n", stu2)

	/*
	   2、取内存地址实例化
	*/
	stu1 := new(Student)
	stu1.name = "baim01"
	stu1.age = 18
	fmt.Printf("%#v\n", stu1)

	stu3 := Student{}
	fmt.Printf("%+v\n", stu3)

	stu4 := &Student{} // 取地址 --> new(student) --> 结构体指针
	(*stu4).name = "dazhi"
	stu4.age = 18 // go语言提供的一个语法糖
	fmt.Printf("%+v\n", stu4)
	//var stu5 *Student // nil
	//stu5.name = "shabi" // 对于一个空地址取值，
	//报错panic: runtime error: invalid memory address or nil pointer dereference
	//fmt.Printf("%+v\n", stu5)
}
